package com.service.lyxmservice.dao.article;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.service.lyxmserviceapi.model.ArticleModel;

@Mapper
public interface ArticleListDao {
		
	/**
	 * 根基模块id查询文章列表
	 * @param id
	 * @return
	 */
		@Select("SELECT t.id,t.title,t.context,DATE_FORMAT(t.create_time,'%Y-%m-%d') AS createTimeStr,t.author_id AS authorId,read_num AS readNum,t.mp_id AS mpId,t.module_id AS moduleId,t.description as description ,t.cover_file_src as coverFileSrc, t.target as target FROM t_article t where t.module_id = #{id} GROUP BY t.create_time DESC")
		@Results({
			@Result(property="author",column="authorId",one=@One(select="com.service.lyxmservice.dao.ArticleDetailDao.findAuthorById")),
			@Result(property="mp",column="mpId",one=@One(select="com.service.lyxmservice.dao.ArticleDetailDao.findMpById")),
			@Result(property="module",column="moduleId",one=@One(select="com.service.lyxmservice.dao.ArticleDetailDao.findModuleById")),
			})
		public List<ArticleModel> getArticleListByModuleId(@Param("id")String id);
	
}
